home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !preview / GFtoXY / c / gftoxy next >
Encoding:
Text File  |  1990-07-26  |  27.3 KB  |  936 lines

  1. #define HIRES
  2. #include "mf.h"
  3. #include "mf_vars.h"
  4.  
  5. /*
  6.  * main() plus other necessary routines for mf
  7.  *
  8.  * Tim Morgan 12/19/85
  9.  */
  10. #include <stdio.h>
  11. #include <string.h>
  12.  
  13. char *gfname;
  14.  
  15. void mf(void);
  16.  
  17. int main(argc, argv)
  18. int argc;
  19. char *argv[];
  20. {
  21.     if (argc != 2) {
  22.         fprintf(stderr, "Usage: %s gffile\n", *argv);
  23.         exit(1);
  24.     }
  25.     gfname = argv[1];
  26.  
  27.     mf();
  28.     return(0);
  29. }
  30.  
  31. /* Simulate eoln function */
  32. boolean eoln(f)
  33. FILE *f;
  34. {
  35.     int c;
  36.  
  37.     if (feof(f)) return(true);  /* Fulfill "weaker" requirement */
  38.     c = getc(f);
  39.     (void) ungetc(c, f);
  40.     return(c == '\n');
  41. }
  42.  
  43. /* Exit */
  44. void cexit(h)
  45. int h;
  46. {
  47.     putchar('\n');
  48.     exit(h);
  49. }
  50.  
  51. integer getbyte(void);
  52. integer gettwobytes(void);
  53. integer getthreebytes(void);
  54. integer signedquad(void);
  55.  
  56. /* Hand-coded to avoid compiler deficiency */
  57. integer firstpar(o)
  58. eightbits o;
  59. {
  60.     if (o <= 63)
  61.         return(o);
  62.     if (o == 64 || o == 71 || o == 245 || o == 246 || o == 239)
  63.         return(getbyte());
  64.     if (o == 65 || o == 72 || o == 240)
  65.         return(gettwobytes());
  66.     if (o == 66 || o == 73 || o == 241)
  67.         return(getthreebytes());
  68.     if (o == 242 || o == 243)
  69.         return(signedquad());
  70.     if (o == 70 || o == 244 || o == 67 || o == 68 || o == 69 ||
  71.         (o >= 248 && o <= 255)) return(0);
  72.     return(o - 74);
  73. }
  74.  
  75. void opengffile(void)
  76. {
  77.     gffile = fopen(gfname, "r");
  78.     if (!gffile) {
  79.         fprintf(stderr, "GF file does not exist!\n");
  80.         exit(1);
  81.     }
  82.     curloc = 0;
  83. }
  84.  
  85. void input_ln(void)
  86. {
  87.     if (gets((char *)buffer) == NULL) {
  88.         fprintf(stderr, "Unexpected EOF!\n");
  89.         exit(1);
  90.     }
  91.     (void) strcat((char *)buffer, " ");
  92. }
  93.  
  94.  
  95. FILE *output;
  96.  
  97. void initialize(void)
  98. {
  99.     integer i;
  100.  
  101. #if 0
  102.     fprintf(stderr, "%s\n", "This is GFtype, C Version 2.2");
  103. #endif
  104.     for (i = 0; i <= 31; i++) 
  105.         xchr[i] = '?';
  106.     xchr[32] = ' ';
  107.     xchr[33] = '!';
  108.     xchr[34] = '"';
  109.     xchr[35] = '#';
  110.     xchr[36] = '$';
  111.     xchr[37] = '%';
  112.     xchr[38] = '&';
  113.     xchr[39] = '\'';
  114.     xchr[40] = '(';
  115.     xchr[41] = ')';
  116.     xchr[42] = '*';
  117.     xchr[43] = '+';
  118.     xchr[44] = ',';
  119.     xchr[45] = '-';
  120.     xchr[46] = '.';
  121.     xchr[47] = '/';
  122.     xchr[48] = '0';
  123.     xchr[49] = '1';
  124.     xchr[50] = '2';
  125.     xchr[51] = '3';
  126.     xchr[52] = '4';
  127.     xchr[53] = '5';
  128.     xchr[54] = '6';
  129.     xchr[55] = '7';
  130.     xchr[56] = '8';
  131.     xchr[57] = '9';
  132.     xchr[58] = ':';
  133.     xchr[59] = ';';
  134.     xchr[60] = '<';
  135.     xchr[61] = '=';
  136.     xchr[62] = '>';
  137.     xchr[63] = '?';
  138.     xchr[64] = '@';
  139.     xchr[65] = 'A';
  140.     xchr[66] = 'B';
  141.     xchr[67] = 'C';
  142.     xchr[68] = 'D';
  143.     xchr[69] = 'E';
  144.     xchr[70] = 'F';
  145.     xchr[71] = 'G';
  146.     xchr[72] = 'H';
  147.     xchr[73] = 'I';
  148.     xchr[74] = 'J';
  149.     xchr[75] = 'K';
  150.     xchr[76] = 'L';
  151.     xchr[77] = 'M';
  152.     xchr[78] = 'N';
  153.     xchr[79] = 'O';
  154.     xchr[80] = 'P';
  155.     xchr[81] = 'Q';
  156.     xchr[82] = 'R';
  157.     xchr[83] = 'S';
  158.     xchr[84] = 'T';
  159.     xchr[85] = 'U';
  160.     xchr[86] = 'V';
  161.     xchr[87] = 'W';
  162.     xchr[88] = 'X';
  163.     xchr[89] = 'Y';
  164.     xchr[90] = 'Z';
  165.     xchr[91] = '[';
  166.     xchr[92] = '\\';
  167.     xchr[93] = ']';
  168.     xchr[94] = '^';
  169.     xchr[95] = '_';
  170.     xchr[96] = '`';
  171.     xchr[97] = 'a';
  172.     xchr[98] = 'b';
  173.     xchr[99] = 'c';
  174.     xchr[100] = 'd';
  175.     xchr[101] = 'e';
  176.     xchr[102] = 'f';
  177.     xchr[103] = 'g';
  178.     xchr[104] = 'h';
  179.     xchr[105] = 'i';
  180.     xchr[106] = 'j';
  181.     xchr[107] = 'k';
  182.     xchr[108] = 'l';
  183.     xchr[109] = 'm';
  184.     xchr[110] = 'n';
  185.     xchr[111] = 'o';
  186.     xchr[112] = 'p';
  187.     xchr[113] = 'q';
  188.     xchr[114] = 'r';
  189.     xchr[115] = 's';
  190.     xchr[116] = 't';
  191.     xchr[117] = 'u';
  192.     xchr[118] = 'v';
  193.     xchr[119] = 'w';
  194.     xchr[120] = 'x';
  195.     xchr[121] = 'y';
  196.     xchr[122] = 'z';
  197.     xchr[123] = '{';
  198.     xchr[124] = '|';
  199.     xchr[125] = '}';
  200.     xchr[126] = '~';
  201.     for (i = 127; i <= 255; i++) 
  202.         xchr[i] = '?';
  203.     for (i = 0; i <= 127; i++) 
  204.         xord[chr(i)] = 32;
  205.     for (i = 32; i <= 126; i++) 
  206.         xord[xchr[i]] = i;
  207.     wantsmnemonics = true;
  208.     wantspixels = true;
  209.     for (i = 0; i <= 255; i++) 
  210.         charptr[i] = -1;
  211.     totalchars = 0;
  212.     minmoverall = maxint;
  213.     maxmoverall = -maxint;
  214.     minnoverall = maxint;
  215.     maxnoverall = -maxint;
  216. }
  217. void jumpout(void)
  218. {
  219.     cexit(0);
  220. }
  221. integer getbyte(void)
  222. {
  223.     integer _result;
  224.     eightbits b;
  225.     if (eof(gffile))
  226.         _result = 0;
  227.     else {
  228.         read(gffile, b);
  229.         curloc = curloc + 1;
  230.         _result = b;
  231.     }
  232.     return(_result);
  233. }
  234. integer gettwobytes(void)
  235. {
  236.     integer _result;
  237.     eightbits a, b;
  238.     read(gffile, a);
  239.     read(gffile, b);
  240.     curloc = curloc + 2;
  241.     _result = (a * 256) + b;
  242.     return(_result);
  243. }
  244. integer getthreebytes(void)
  245. {
  246.     integer _result;
  247.     eightbits a, b, c;
  248.     read(gffile, a);
  249.     read(gffile, b);
  250.     read(gffile, c);
  251.     curloc = curloc + 3;
  252.     _result = (((a * 256) + b) * 256) + c;
  253.     return(_result);
  254. }
  255. integer signedquad(void)
  256. {
  257.     integer _result;
  258.     eightbits a, b, c, d;
  259.     read(gffile, a);
  260.     read(gffile, b);
  261.     read(gffile, c);
  262.     read(gffile, d);
  263.     curloc = curloc + 4;
  264.     if (a < 128)
  265.         _result = (((((a * 256) + b) * 256) + c) * 256) + d;
  266.     else
  267.         _result = ((((((a - 256) * 256) + b) * 256) + c) * 256) + d;
  268.     return(_result);
  269. }
  270. ASCIIcode lowercasify(c)
  271. ASCIIcode c;
  272. {
  273.     ASCIIcode _result;
  274.     if ((c >= 65) && (c <= 90))
  275.         _result = c + 32;
  276.     else
  277.         _result = c;
  278.     return(_result);
  279. }
  280. void dialog(void)
  281. {
  282. L1:
  283.     buffer[0] = 'n';
  284.     if (buffer[0] != 63)
  285.         wantsmnemonics = 
  286.           (((buffer[0] == 121)
  287.          || (buffer[0] == 49))
  288.          || (buffer[0] == 116))
  289.          || (buffer[0] == 32);
  290.     else {
  291.         printf("%s", "Type Y for complete listing,");
  292.         printf("%s\n", " N for errors/images only.");
  293.         goto L1;
  294.     }
  295. L2:
  296.     buffer[0] = 'y';
  297.     if (buffer[0] != 63)
  298.         wantspixels = 
  299.           (((buffer[0] == 121)
  300.          || (buffer[0] == 49))
  301.          || (buffer[0] == 116))
  302.          || (buffer[0] == 32);
  303.     else {
  304.         printf("%s", "Type Y to list characters pictorially");
  305.         printf("%s\n", " with *\'s, N to omit this option.");
  306.         goto L2;
  307.     }
  308.     fprintf(stderr, "%s", "Options selected: Mnemonic output = ");
  309.     if (wantsmnemonics)
  310.         fprintf(stderr, "%s", "true");
  311.     else
  312.         fprintf(stderr, "%s", "false");
  313.     fprintf(stderr, "%s", "; pixel output = ");
  314.     if (wantspixels)
  315.         fprintf(stderr, "%s", "true");
  316.     else
  317.         fprintf(stderr, "%s", "false");
  318.     fprintf(stderr, "%c\n", '.');
  319. }
  320. void printscaled(s)
  321. integer s;
  322. {
  323.     integer delta;
  324.     if (s < 0) {
  325.         fprintf(stderr, "%c", '-');
  326.         s = -s;
  327.     }
  328.     fprintf(stderr, "%d", s / 65536);
  329.     s = (10 * (s%65536)) + 5;
  330.     if (s != 5) {
  331.         delta = 10;
  332.         fprintf(stderr, "%c", '.');
  333.         do {
  334.             if (delta > 65536)
  335.                 s = (s + 32768) - (delta/2);
  336.             fprintf(stderr, "%c", chr(ord('0') + (s / 65536)));
  337.             s = 10 * (s%65536);
  338.             delta = delta * 10;
  339.         } while (! (s <= delta));
  340.     }
  341. }
  342. boolean dochar(void)
  343. {
  344.     boolean _result;
  345.     eightbits o;
  346.     integer p, q;
  347.     boolean aok;
  348.     aok = true;
  349.  
  350.     select_char(c,
  351.                 minmstated, maxmstated,
  352.                 minnstated, maxnstated); /* TeX character we are defining */
  353.                                          /* and limits of pixels */
  354.     while (true){
  355.         a = curloc;
  356.         o = getbyte();
  357.         p = firstpar(o);
  358.         if (eof(gffile)) {
  359.             fprintf(stderr, "%c%s%s%c",
  360.               ' ', "Bad GF file: ", "the file ended prematurely", '!');
  361.             jumpout();
  362.         }
  363.         if (o <= 67) {
  364.             if (wantsmnemonics)
  365.                 fprintf(stderr, "%s", " paint ");
  366.             do {
  367.                 if (wantsmnemonics) {
  368.                     if (paintswitch == 0)
  369.                         fprintf(stderr, "%c%d%c", '(', p, ')');
  370.                     else
  371.                         fprintf(stderr, "%d", p);
  372.                 }
  373.                 m = m + p;
  374.                 if (m > maxmobserved)
  375.                     maxmobserved = m - 1;
  376.                 if (wantspixels)
  377.                     if (paintswitch == 1)
  378.                         if (n <= maxsubrow) {
  379.                             l = m - p;
  380.                             r = m - 1;
  381.                             if (r > maxsubcol)
  382.                                 r = maxsubcol;
  383.                             m = l;
  384.                             while (m <= r){
  385. #ifdef NEVER
  386.                                 imagearray[m][n] = 1;
  387. #endif
  388.                                 set_pixel(n, m);
  389.                                 m = m + 1;
  390.                             }
  391.                             m = l + p;
  392.                         }
  393.                 paintswitch = 1 - paintswitch;
  394.                 a = curloc;
  395.                 o = getbyte();
  396.                 p = firstpar(o);
  397.                 if (eof(gffile)) {
  398.                     fprintf(stderr, "%c%s%s%c",
  399.                       ' ', "Bad GF file: ", "the file ended prematurely", '!');
  400.                     jumpout();
  401.                 }
  402.             } while (! (o > 67));
  403.         }
  404.         if (o >= 70 && o <= 73) {
  405.                 {
  406.                     if (wantsmnemonics) {
  407.                         fprintf(stderr, "\n");
  408.                         fprintf(stderr, "%d%s%s%d%c%d",
  409.                           a, ": ", "skip", (o - 70) % 4, ' ', p);
  410.                     }
  411.                     n = (n + p) + 1;
  412.                     m = 0;
  413.                     paintswitch = 0;
  414.                     if (wantsmnemonics)
  415.                         fprintf(stderr, "%s%d%c", " (n=", maxnstated - n, ')');
  416.                 }
  417.         } else if (o >= 74 && o <= 238) {
  418.                 {
  419.                     if (wantsmnemonics) {
  420.                         fprintf(stderr, "\n");
  421.                         fprintf(stderr, "%d%s%s%d", a, ": ", "newrow ", p);
  422.                     }
  423.                     n = n + 1;
  424.                     m = p;
  425.                     paintswitch = 1;
  426.                     if (wantsmnemonics)
  427.                         fprintf(stderr, "%s%d%c", " (n=", maxnstated - n, ')');
  428.                 }
  429.         } else if (o == 244) {
  430.                 if (wantsmnemonics) {
  431.                     fprintf(stderr, "\n");
  432.                     fprintf(stderr, "%d%s%s", a, ": ", "no op");
  433.                 }
  434.         } else if (o == 247) {
  435.                 {
  436.                     {
  437.                         fprintf(stderr, "%d%s%s%s",
  438.                           a, ": ", "! ",
  439.                           "preamble command within a character!");
  440.                         fprintf(stderr, "\n");
  441.                     }
  442.                     goto L9998;
  443.                 }
  444.         } else if (o == 248 || o == 249) {
  445.                 {
  446.                     {
  447.                         fprintf(stderr, "%d%s%s%s",
  448.                           a, ": ", "! ",
  449.                           "postamble command within a character!");
  450.                         fprintf(stderr, "\n");
  451.                     }
  452.                     goto L9998;
  453.                 }
  454.                 break;
  455.         } else if (o == 67 || o == 68) {
  456.                 {
  457.                     {
  458.                         fprintf(stderr, "%d%s%s%s",
  459.                           a, ": ", "! ", "boc occurred before eoc!");
  460.                         fprintf(stderr, "\n");
  461.                     }
  462.                     goto L9998;
  463.                 }
  464.         } else if (o == 69) {
  465.                 {
  466.                     if (wantsmnemonics) {
  467.                         fprintf(stderr, "\n");
  468.                         fprintf(stderr, "%d%s%s", a, ": ", "eoc");
  469.                     }
  470. #ifdef NEVER
  471.                     fprintf(stderr, "\n");
  472. #endif
  473.                     goto L9999;
  474.                 }
  475.         } else if (o >= 239 && o <= 242) {
  476.                 {
  477.                     if (wantsmnemonics) {
  478.                         fprintf(stderr, "\n");
  479.                         fprintf(stderr, "%d%s%s", a, ": ", "xxx \'");
  480.                     }
  481.                     badchar = false;
  482.                     b = 16;
  483.                     if (p < 0) {
  484.                         fprintf(stderr, "\n");
  485.                         fprintf(stderr, "%d%s%s%s",
  486.                           a, ": ", "! ", "string of negative length!");
  487.                         fprintf(stderr, "\n");
  488.                     }
  489.                     while (p > 0){
  490.                         q = getbyte();
  491.                         if ((q < 32) || (q > 126))
  492.                             badchar = true;
  493.                         if (wantsmnemonics) {
  494.                             fprintf(stderr, "%c", xchr[q]);
  495.                             if (b < linelength)
  496.                                 b = b + 1;
  497.                             else {
  498.                                 fprintf(stderr, "\n");
  499.                                 b = 2;
  500.                             }
  501.                         }
  502.                         p = p - 1;
  503.                     }
  504.                     if (wantsmnemonics)
  505.                         fprintf(stderr, "%c", '\'');
  506.                     if (badchar) {
  507.                         fprintf(stderr, "\n");
  508.                         fprintf(stderr, "%d%s%s%s",
  509.                           a, ": ", "! ",
  510.                           "non-ASCII character in xxx command!");
  511.                         fprintf(stderr, "\n");
  512.                     }
  513.                 }
  514.         } else if (o == 243) {
  515.                 {
  516.                     if (wantsmnemonics) {
  517.                         fprintf(stderr, "\n");
  518.                         fprintf(stderr, "%d%s%s%d%s",
  519.                           a, ": ", "yyy ", p, " (");
  520.                     }
  521.                     if (wantsmnemonics) {
  522.                         printscaled(p);
  523.                         fprintf(stderr, "%c", ')');
  524.                     }
  525.                 }
  526.                 break;
  527.         } else {
  528.                 {
  529.                     fprintf(stderr, "%d%s%s%s%d%c",
  530.                       a, ": ", "! ", "undefined command ", o, '!');
  531.                     fprintf(stderr, "\n");
  532.                 }
  533.         }
  534.     }
  535. L9998:
  536.     fprintf(stderr, "%c\n", '!');
  537.     aok = false;
  538. L9999:
  539.     _result = aok;
  540.     dump_char();
  541.     return(_result);
  542. }
  543. void readpostamble(void)
  544. {
  545.     integer k;
  546.     integer p, q, m, u, v, w, c;
  547.     postloc = curloc - 1;
  548.     fprintf(stderr, "%s%d", "Postamble starts at byte ", postloc);
  549.     if (postloc == gfprevptr)
  550.         fprintf(stderr, "%c\n", '.');
  551.     else
  552.         fprintf(stderr, "%s%d%c\n",
  553.           ", after special info at byte ", gfprevptr, '.');
  554.     p = signedquad();
  555.     if (p != gfprevptr) {
  556.         fprintf(stderr, "%d%s%s%s%d%s%d%s%d%c",
  557.           a, ": ", "! ",
  558.           "backpointer in byte ", curloc - 4,
  559.           " should be ", gfprevptr, " not ", p, '!');
  560.         fprintf(stderr, "\n");
  561.     }
  562.     designsize = signedquad();
  563.     checksum = signedquad();
  564.     fprintf(stderr, "%s%d%s", "design size = ", designsize, " (");
  565.     printscaled(designsize / 16);
  566.     fprintf(stderr, "%s\n", "pt)");
  567.     fprintf(stderr, "%s%d\n", "check sum = ", checksum);
  568.     hppp = signedquad();
  569.     vppp = signedquad();
  570.     fprintf(stderr, "%s%d%s", "hppp = ", hppp, " (");
  571.     printscaled(hppp);
  572.     fprintf(stderr, "%c\n", ')');
  573.     fprintf(stderr, "%s%d%s", "vppp = ", vppp, " (");
  574.     printscaled(vppp);
  575.     fprintf(stderr, "%c\n", ')');
  576.     pixratio = (designsize / 1048576.0) * (hppp / 1048576.0);
  577.     minmstated = signedquad();
  578.     maxmstated = signedquad();
  579.     minnstated = signedquad();
  580.     maxnstated = signedquad();
  581.     fprintf(stderr, "%s%d%s%d\n",
  582.       "min m = ", minmstated, ", max m = ", maxmstated);
  583.     if (minmstated > minmoverall) {
  584.         fprintf(stderr, "%d%s%s%s%d%c",
  585.           a, ": ", "! ", "min m should be <=", minmoverall, '!');
  586.         fprintf(stderr, "\n");
  587.     }
  588.     if (maxmstated < maxmoverall) {
  589.         fprintf(stderr, "%d%s%s%s%d%c",
  590.           a, ": ", "! ", "max m should be >=", maxmoverall, '!');
  591.         fprintf(stderr, "\n");
  592.     }
  593.     fprintf(stderr, "%s%d%s%d\n",
  594.       "min n = ", minnstated, ", max n = ", maxnstated);
  595.     if (minnstated > minnoverall) {
  596.         fprintf(stderr, "%d%s%s%s%d%c",
  597.           a, ": ", "! ", "min n should be <=", minnoverall, '!');
  598.         fprintf(stderr, "\n");
  599.     }
  600.     if (maxnstated < maxnoverall) {
  601.         fprintf(stderr, "%d%s%s%s%d%c",
  602.           a, ": ", "! ", "max n should be >=", maxnoverall, '!');
  603.         fprintf(stderr, "\n");
  604.     }
  605.     do {
  606.         a = curloc;
  607.         k = getbyte();
  608.         if ((k == 245) || (k == 246)) {
  609.             c = firstpar(k);
  610.             if (k == 245) {
  611.                 u = signedquad();
  612.                 v = signedquad();
  613.             }
  614.             else {
  615.                 u = getbyte() * 65536;
  616.                 v = 0;
  617.             }
  618.             w = signedquad();
  619.             p = signedquad();
  620.             fprintf(stderr, "%s%d%s%d%s", "Character ", c, ": dx ", u, " (");
  621.             printscaled(u);
  622.             if (v != 0) {
  623.                 fprintf(stderr, "%s%d%s", "), dy ", v, " (");
  624.                 printscaled(v);
  625.             }
  626.             fprintf(stderr, "%s%d%s", "), width ", w, " (");
  627.             w = round(w * pixratio);
  628.             select_char2(c, w, 1);
  629.             fprintf (stderr, "%d", w);
  630.             fprintf(stderr, "%s%d\n", "), loc ", p);
  631.             if (p != charptr[c]) {
  632.                 fprintf(stderr, "%d%s%s%s%d%c",
  633.                   a, ": ", "! ",
  634.                   "character location should be ", charptr[c], '!');
  635.                 fprintf(stderr, "\n");
  636.             }
  637.             k = 244;
  638.         }
  639.     } while (! (k != 244));
  640.     if (k != 249) {
  641.         fprintf(stderr, "%d%s%s%s", a, ": ", "! ", "should be postpost!");
  642.         fprintf(stderr, "\n");
  643.     }
  644.     q = signedquad();
  645.     if (q != postloc) {
  646.         fprintf(stderr, "%d%s%s%s%d%s%d",
  647.           a, ": ", "! ", "postamble pointer should be ", postloc, " not ", q);
  648.         fprintf(stderr, "\n");
  649.     }
  650.     m = getbyte();
  651.     if (m != 131) {
  652.         fprintf(stderr, "%d%s%s%s%d%s%d",
  653.           a, ": ", "! ", "identification byte should be ", 131, ", not ", m);
  654.         fprintf(stderr, "\n");
  655.     }
  656.     k = curloc;
  657.     m = 223;
  658.     while ((m == 223) && (! eof(gffile)))
  659.         m = getbyte();
  660.     if (! eof(gffile)) {
  661.         fprintf(stderr, "%c%s%s%d%s%c",
  662.           ' ', "Bad GF file: ", "signature in byte ", curloc - 1,
  663.           " should be 223", '!');
  664.         jumpout();
  665.     }
  666.     else if (curloc < (k + 4)) {
  667.         fprintf(stderr, "%d%s%s%s",
  668.           a, ": ", "! ", "not enough signature bytes at end of file!");
  669.         fprintf(stderr, "\n");
  670.     }
  671. }
  672. void mf(void)
  673. {
  674.     initialize();
  675.     make_sprites(gfname);
  676.     begin_dump_sprites();
  677.     dialog();
  678.     opengffile();
  679.     o = getbyte();
  680.     if (o != 247) {
  681.         fprintf(stderr, "%c%s%s%c",
  682.           ' ', "Bad GF file: ", "First byte isn\'t start of preamble!", '!');
  683.         jumpout();
  684.     }
  685.     o = getbyte();
  686.     if (o != 131) {
  687.         fprintf(stderr, "%c%s%s%d%s%d%c",
  688.           ' ', "Bad GF file: ", "identification byte should be ", 131,
  689.           " not ", o, '!');
  690.         jumpout();
  691.     }
  692.     o = getbyte();
  693.     fprintf(stderr, "%c", '\'');
  694.     while (o > 0){
  695.         o = o - 1;
  696.         fprintf(stderr, "%c", xchr[getbyte()]);
  697.     }
  698.     fprintf(stderr, "%c\n", '\'');
  699.     do {
  700.         gfprevptr = curloc;
  701.         do {
  702.             a = curloc;
  703.             o = getbyte();
  704.             p = firstpar(o);
  705.             if (eof(gffile)) {
  706.                 fprintf(stderr, "%c%s%s%c",
  707.                   ' ', "Bad GF file: ", "the file ended prematurely", '!');
  708.                 jumpout();
  709.             }
  710.             if (o == 243) {
  711.                 {
  712.                     if (wantsmnemonics) {
  713.                         fprintf(stderr, "\n");
  714.                         fprintf(stderr, "%d%s%s%d%s",
  715.                           a, ": ", "yyy ", p, " (");
  716.                     }
  717.                     if (wantsmnemonics) {
  718.                         printscaled(p);
  719.                         fprintf(stderr, "%c", ')');
  720.                     }
  721.                 }
  722.                 o = 244;
  723.             }
  724.             else if ((o >= 239) && (o <= 242)) {
  725.                 {
  726.                     if (wantsmnemonics) {
  727.                         fprintf(stderr, "\n");
  728.                         fprintf(stderr, "%d%s%s", a, ": ", "xxx \'");
  729.                     }
  730.                     badchar = false;
  731.                     b = 16;
  732.                     if (p < 0) {
  733.                         fprintf(stderr, "\n");
  734.                         fprintf(stderr, "%d%s%s%s",
  735.                           a, ": ", "! ", "string of negative length!");
  736.                         fprintf(stderr, "\n");
  737.                     }
  738.                     while (p > 0){
  739.                         q = getbyte();
  740.                         if ((q < 32) || (q > 126))
  741.                             badchar = true;
  742.                         if (wantsmnemonics) {
  743.                             fprintf(stderr, "%c", xchr[q]);
  744.                             if (b < linelength)
  745.                                 b = b + 1;
  746.                             else {
  747.                                 fprintf(stderr, "\n");
  748.                                 b = 2;
  749.                             }
  750.                         }
  751.                         p = p - 1;
  752.                     }
  753.                     if (wantsmnemonics)
  754.                         fprintf(stderr, "%c", '\'');
  755.                     if (badchar) {
  756.                         fprintf(stderr, "\n");
  757.                         fprintf(stderr, "%d%s%s%s",
  758.                           a, ": ", "! ",
  759.                           "non-ASCII character in xxx command!");
  760.                         fprintf(stderr, "\n");
  761.                     }
  762.                 }
  763.                 o = 244;
  764.             }
  765.             else if (o == 244)
  766.                 if (wantsmnemonics) {
  767.                     fprintf(stderr, "\n");
  768.                     fprintf(stderr, "%d%s%s", a, ": ", "no op");
  769.                 }
  770.         } while (! (o != 244));
  771.         if (o != 248) {
  772.             if (o != 67)
  773.                 if (o != 68) {
  774.                     fprintf(stderr, "%c%s%s%d%s%d%c%c",
  775.                       ' ', "Bad GF file: ", "byte ", curloc - 1,
  776.                       " is not boc (", o, ')', '!');
  777.                     jumpout();
  778.                 }
  779. #if 0
  780.             fprintf(stderr, "\n");
  781.             fprintf(stderr, "%d%s", curloc - 1, ": beginning of char ");
  782. #endif
  783.             a = curloc - 1;
  784.             totalchars = totalchars + 1;
  785.             if (o == 67) {
  786.                 charactercode = signedquad();
  787.                 p = signedquad();
  788.                 c = charactercode%256;
  789.                 if (c < 0)
  790.                     c = c + 256;
  791.                 minmstated = signedquad();
  792.                 maxmstated = signedquad();
  793.                 minnstated = signedquad();
  794.                 maxnstated = signedquad();
  795.             }
  796.             else {
  797.                 charactercode = getbyte();
  798.                 p = -1;
  799.                 c = charactercode;
  800.                 q = getbyte();
  801.                 maxmstated = getbyte();
  802.                 minmstated = maxmstated - q;
  803.                 q = getbyte();
  804.                 maxnstated = getbyte();
  805.                 minnstated = maxnstated - q;
  806.             }
  807. #if 0
  808.             fprintf(stderr, "%d", c);
  809.             if (charactercode != c)
  810.                 fprintf(stderr, "%s%d",
  811.                   " with extension ", (charactercode - c) / 256);
  812.             if (wantsmnemonics)
  813.                 fprintf(stderr, "%s%d%s%d%c%d%s%d\n",
  814.                   ": ", minmstated, "<=m<=", maxmstated, ' ', minnstated,
  815.                   "<=n<=", maxnstated);
  816. #endif
  817.             maxmobserved = -1;
  818.             if (charptr[c] != p) {
  819.                 fprintf(stderr, "%d%s%s%s%d%s%d%c",
  820.                   a, ": ", "! ", "previous character pointer should be ",
  821.                   charptr[c], ", not ", p, '!');
  822.                 fprintf(stderr, "\n");
  823.             }
  824.             else if (p > 0)
  825.                 if (wantsmnemonics)
  826.                     fprintf(stderr, "%s%d%c\n",
  827.                      "(previous character with the same code started at byte ",
  828.                      p, ')');
  829.             charptr[c] = gfprevptr;
  830.             if (wantsmnemonics)
  831.                 fprintf(stderr, "%s%d%c", "(initially n=", maxnstated, ')');
  832.             if (wantspixels) {
  833.                 maxsubcol = (maxmstated - minmstated) - 1;
  834.                 if (maxsubcol > maxcol)
  835.                     maxsubcol = maxcol;
  836.                 maxsubrow = maxnstated - minnstated;
  837.                 if (maxsubrow > maxrow)
  838.                     maxsubrow = maxrow;
  839.                 n = 0;
  840.                 while (n <= maxsubrow){
  841.                     m = 0;
  842.                     while (m <= maxsubcol){
  843. #ifdef NEVER
  844.                         imagearray[m][n] = 0;
  845. #endif
  846.                         m = m + 1;
  847.                     }
  848.                     n = n + 1;
  849.                 }
  850.             }
  851.             m = 0;
  852.             n = 0;
  853.             paintswitch = 0;
  854.             if (! dochar()) {
  855.                 fprintf(stderr, "%c%s%s%c",
  856.                   ' ', "Bad GF file: ", "char ended unexpectedly", '!');
  857.                 jumpout();
  858.             }
  859.             maxnobserved = n;
  860.             if (wantspixels) {
  861.                 if ((maxmobserved > maxcol) || (maxnobserved > maxrow))
  862.                     fprintf(stderr, "%s\n",
  863.                       "(The character is too large to be displayed in full.)");
  864.                 if (maxsubcol > maxmobserved)
  865.                     maxsubcol = maxmobserved;
  866.                 if (maxsubrow > maxnobserved)
  867.                     maxsubrow = maxnobserved;
  868.                 if (maxsubcol >= 0) {
  869. #if 0
  870.                     fprintf(stderr, "%s%d%c%d%s\n",
  871.                       ".<--This pixel\'s lower left corner is at (",
  872.                       minmstated, ',', maxnstated + 1,
  873.                       ") in METAFONT coordinates");
  874. #endif
  875. #ifdef NEVER
  876.                     n = 0;
  877.                     while (n <= maxsubrow){
  878.                         m = 0;
  879.                         b = 0;
  880.                         while (m <= maxsubcol){
  881.                             if (imagearray[m][n] == 0)
  882.                                 b = b + 1;
  883.                             else {
  884.                                 while (b > 0){
  885.                                     fprintf(stderr, "%c", ' ');
  886.                                     b = b - 1;
  887.                                 }
  888.                                 fprintf(stderr, "%c", '*');
  889.                             }
  890.                             m = m + 1;
  891.                         }
  892.                         fprintf(stderr, "\n");
  893.                         n = n + 1;
  894.                     }
  895. #endif
  896. #if 0
  897.                     fprintf(stderr, "%s%d%c%d%s\n",
  898.                       ".<--This pixel\'s upper left corner is at (",
  899.                       minmstated, ',', maxnstated - maxsubrow,
  900.                       ") in METAFONT coordinates");
  901. #endif
  902.                 }
  903. #if 0
  904.                 else
  905.                     fprintf(stderr, "%s\n",
  906.                       "(The character is entirely blank.)");
  907. #endif
  908.             }
  909.             maxmobserved = (minmstated + maxmobserved) + 1;
  910.             n = maxnstated - maxnobserved;
  911.             if (minmstated < minmoverall)
  912.                 minmoverall = minmstated;
  913.             if (maxmobserved > maxmoverall)
  914.                 maxmoverall = maxmobserved;
  915.             if (n < minnoverall)
  916.                 minnoverall = n;
  917.             if (maxnstated > maxnoverall)
  918.                 maxnoverall = maxnstated;
  919.             if (maxmobserved > maxmstated)
  920.                 fprintf(stderr, "%s%d\n",
  921.                   "The previous character should have had max m >= ",
  922.                   maxmobserved);
  923.             if (n < minnstated)
  924.                 fprintf(stderr, "%s%d\n",
  925.                   "The previous character should have had min n <= ", n);
  926.         }
  927.     } while (! (o == 248));
  928.     fprintf(stderr, "\n");
  929.     readpostamble();
  930.     fprintf(stderr, "%s%d%s", "The file had ", totalchars, " character");
  931.     if (totalchars != 1)
  932.         fprintf(stderr, "%c", 's');
  933.     fprintf(stderr, "%s", " altogether.\n");
  934.     end_dump_sprites();
  935. }
  936.